{% extends 'base_generic.html' %}

{% block content %}
<div class="container py-4">
  <h2 class="mb-4">我的主页</h2>
  <div class="card mb-4">
    <div class="card-body">
      <h5 class="card-title">基本信息</h5>
      <p><strong>用户名：</strong>{{ user.username }}</p>
      <p><strong>邮箱：</strong>{{ user.email }}</p>
    </div>
  </div>

  <div class="row">
    <div class="col-md-6">
      <div class="card mb-4">
        <div class="card-body">
          <h5 class="card-title">我的借阅</h5>
          {% if borrowed %}
            <ul>
              {% for inst in borrowed %}
                <li><a href="{{ inst.book.get_absolute_url }}">{{ inst.book.title }}</a> - 状态: {{ inst.get_status_display }} {% if inst.due_back %} (归还日期: {{ inst.due_back }}){% endif %}</li>
              {% endfor %}
            </ul>
          {% else %}
            <p>暂无借阅记录。</p>
          {% endif %}
        </div>
      </div>
      <div class="card mb-4">
        <div class="card-body">
          <h5 class="card-title">我的收藏</h5>
          {% if favorites %}
            <ul>
              {% for fav in favorites %}
                <li><a href="{{ fav.book.get_absolute_url }}">{{ fav.book.title }}</a></li>
              {% endfor %}
            </ul>
          {% else %}
            <p>暂无收藏。</p>
          {% endif %}
        </div>
      </div>
    </div>
    <div class="col-md-6">
      <div class="card mb-4">
        <div class="card-body">
          <h5 class="card-title">我的点赞</h5>
          {% if likes %}
            <ul>
              {% for like in likes %}
                <li><a href="{{ like.book.get_absolute_url }}">{{ like.book.title }}</a></li>
              {% endfor %}
            </ul>
          {% else %}
            <p>暂无点赞。</p>
          {% endif %}
        </div>
      </div>
      <div class="card mb-4">
        <div class="card-body">
          <h5 class="card-title">我的评论</h5>
          {% if reviews %}
            <ul>
              {% for review in reviews %}
                <li><a href="{{ review.book.get_absolute_url }}">{{ review.book.title }}</a>：{{ review.comment|truncatechars:30 }}</li>
              {% endfor %}
            </ul>
          {% else %}
            <p>暂无评论。</p>
          {% endif %}
        </div>
      </div>
    </div>
  </div>
</div>
{% endblock %} 